﻿using System;
using Xunit;
using Glue.Internals;

namespace GlueTests.TypeExtensionTests
{
    public class When_checking_if_primitive
    {
        [Fact]
        public void Primitives_Should_be_primitive()
        {
            Assert.True(typeof(int).IsPrimitive());
        }

        [Fact]
        public void Decimal_Should_be_primitive()
        {
            Assert.True(typeof(decimal).IsPrimitive());
        }

        [Fact]
        public void Strings_Should_be_primitive()
        {
            Assert.True(typeof(String).IsPrimitive());
        }

        public enum EnumsArePrimitives { First, Second, Third }

        [Fact]
        public void Enums_Should_be_primitive()
        {
            Assert.True(typeof(EnumsArePrimitives).IsPrimitive());
        }

        [Fact]
        public void DateTime_Should_be_primitive()
        {
            Assert.True(typeof(DateTime).IsPrimitive());
        }

        [Fact]
        public void TimeSpan_Should_be_primitive()
        {
            Assert.True(typeof(TimeSpan).IsPrimitive());
        }

        [Fact]
        public void Guid_Should_be_primitive()
        {
            Assert.True(typeof(Guid).IsPrimitive());
        }

        [Fact]
        public void Objects_Should_not_be_primitive()
        {
            Assert.False(GetType().IsPrimitive());
        }

        [Fact]
        public void Arrays_Should_not_be_primitive()
        {
            Assert.False(typeof(int[]).IsPrimitive());
        }

        [Fact]
        public void Nullables_with_primitive_underlyingType_Should_be_primitive()
        {
            Assert.True(typeof(double?).IsPrimitive());
        }

    }
}
